package com.allwees.bs.module.scm.req;

import com.allwees.bs.core.modelbase.validate.ValidateItem;
import com.allwees.bs.module.scm.constant.ELogisticsType;
import lombok.Data;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * 发货信息
 * @author mouhn
 * @since 2019-12-31 15:29
 */
@Data
public class PickOrderSkuShippingReq extends BatchPickOrderSkuReq {

    /** 物流方式 **/
    private ELogisticsType logisticsType;

    /** 收货地址uuid **/
    private String receiveAddressUuid;

    /** 运单号 **/
    private String expressCode;

    //=========平台合作=======

    /** 预约年月日 **/
    private Date reserveDate;

    /** 预约时间范围 **/
    private String reserveRange;

    //=========三方物流=======

    /** 物流公司 **/
    private String logisticsUuid;

    @Override
    public ValidateItem[] getValidateItems() {
        return ArrayUtils.addAll(
                super.getValidateItems(),
                new ValidateItem(logisticsType == null, "发货物流类型不能为空"),
                new ValidateItem(StringUtils.isBlank(receiveAddressUuid), "收货地址不能为空"),
                new ValidateItem(ELogisticsType.OPTIONAL.equals(logisticsType) && logisticsUuid == null, "物流公司不能为空"),
                new ValidateItem(ELogisticsType.PLATFORM.equals(logisticsType) && reserveDate == null, "预约日期不能为空"),
                new ValidateItem(ELogisticsType.PLATFORM.equals(logisticsType) && reserveRange == null, "预约时间段不能为空"),
                new ValidateItem(StringUtils.isBlank(expressCode), "运单号不能为空")
        );
    }
}
